<html xmlns:th="http://www.thymeleaf.org" lang="zh-CN">
<head th:replace="common/layout :: common_header(~{::title},~{::link})">
<title>新建角色</title>
</head>
<body>
	<div class="main-container">
		<div class="main-content-inner">
			<div class="page-content">
				<div class="row">
					<form class="form-horizontal" role="form" id="userAddForm" method="post" th:action="@{/sys/role/save}" >
						<div class="form-group">
                          <label class="col-sm-2 control-label" for="ds_name">角色名称</label>
                          <div class="col-sm-4">
                             <input class="form-control" id="ds_name" name="name" type="text" placeholder="请输入角色名称" required/>
                          </div>
                          <label class="col-sm-2 control-label" for="ds_enname">角色编码</label>
                          <div class="col-sm-4">
                             <input class="form-control" id="ds_enname" name="enname" type="text" placeholder="请输入角色编码" required/>
                          </div>
                       </div>
                       <div class="form-group">
                          <label class="col-sm-2 control-label" for="ds_roleType">角色类型</label>
                          <div class="col-sm-4">
                             <input class="form-control" id="ds_roleType" name="roleType" type="text"  required/>
                          </div>
                          <label class="col-sm-2 control-label" for="ds_isSys">是否系统数据</label>
                          <div class="col-sm-4">
                          	<select class="form-control" id="ds_isSys" name="isSys">
							<option value="1">是</option>
							<option value="0">否</option>
							</select>
                          </div>
                       </div>
                       <div class="form-group">
                          <label class="col-sm-2 control-label" for="ds_useable">是否可用</label>
                          <div class="col-sm-4">
                          <select class="form-control" id="ds_useable"  name="useable" >
                             	<option value="1">可用</option>
                             	<option value="0">禁用</option>
                             </select>
                          </div>
                          <label class="col-sm-2 control-label" for="ds_remarks">备注</label>
                          <div class="col-sm-4">
                             <textarea class="form-control" id="ds_remarks" name="remarks" ></textarea>
                          </div>
                       </div>
                        
                       <div class="clearfix ">
										<div class="center">
											<button class="btn btn-info" type="submit" id="submitBtn">
												<i class="ace-icon fa fa-check bigger-110"></i>
												保存
											</button>

											&nbsp; &nbsp; &nbsp;
											<button class="btn" type="button" id="closeWin">
												<i class="ace-icon fa fa-del bigger-110"></i>
												关闭
											</button>
										</div>
									</div>
					</form>
				</div>
				<!-- /.col -->
			</div>

		</div>
		<!-- end main container -->
	</div>

	<div th:replace="common/commonJS"></div>
	<script type="text/javascript">
	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
	//关闭iframe
	$('#closeWin').click(function(){
	    top.layer.close(index);
	});
	    
	 $().ready(function() {
		    $("#userAddForm").validate({
		    	submitHandler: function(form) { 
	        		//验证通过后 的js代码写在这里 
	        		
		    		 $(form).ajaxSubmit({
		                 dataType:"json",
		                 success:function( data ){
		                      if(data==1){
		                    	  top.layer.alert('保存成功') 
		                    	  top.layer.close(index);
		                    	  if(top.getActiveTab()[0]){
		                    		  top.getActiveTab()[0].contentWindow.search();
		                    	  }
		                    	  
		                      }else{
		                    	  top.layer.alert('保存失败')  
		                      }
		                        
		                    
		                   },
		                   error:function(xhr, status, error){
		                	   top.layer.alert('操作失败');
		                   }
		                 });
	         
	        		}
		    });
		});
	</script>
</body>
</html>